package com.wlyuan.open.controller;

import com.wlyuan.open.api.IOpenSyncService;
import com.wlyuan.open.dto.*;
import com.wlyuan.open.dto.tenant.OpenCompanyTenantSyncDTO;
import com.wlyuan.open.dto.tenant.OpenDriverTenantSyncDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author lijing
 */
@Api(tags = "同步")
@Validated
@RequestMapping("")
@RestController
public class OpenSyncController {
    @DubboReference(check = false)
    private IOpenSyncService openSyncService;

    @ApiOperation("同步承运方")
    @PostMapping("/carrier/sync")
    public void sync(@RequestBody @Valid OpenCarrierSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步收货方")
    @PostMapping("/consignee/sync")
    public void sync(@RequestBody @Valid OpenConsigneeSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步发货方")
    @PostMapping("/customer/sync")
    public void sync(@RequestBody @Valid OpenCustomerSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步司机")
    @PostMapping("/driver/sync")
    public void sync(@RequestBody @Valid OpenDriverSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步车辆")
    @PostMapping("/vehicle/sync")
    public void sync(@RequestBody @Valid OpenVehicleSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步对账单")
    @PostMapping("/finance/sync")
    public void sync(@RequestBody @Valid OpenBillSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步收付款信息")
    @PostMapping("/finance/sync/pay")
    public void syncPay(@RequestBody @Valid OpenPaySyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步物品")
    @PostMapping("/goods/sync")
    public void sync(@RequestBody @Valid OpenGoodsSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步订单")
    @PostMapping("/order/sync")
    public void sync(@RequestBody @Valid OpenOrderSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步报价")
    @PostMapping("/quotation/sync")
    public void sync(@RequestBody @Valid OpenQuotationSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步合约")
    @PostMapping("/quotation/sync/template")
    public void syncTemplate(@RequestBody @Valid OpenTemplateSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步用户")
    @PostMapping("/user/sync")
    public void sync(@RequestBody @Valid OpenUserSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步运单")
    @PostMapping("/transport/sync")
    public void sync(@RequestBody @Valid OpenTransportSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步拼单")
    @PostMapping("/transport/sync/combine")
    public void sync(@RequestBody @Valid OpenCombineSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步企业租户")
    @PostMapping("/tenant/sync")
    public void sync(@RequestBody @Valid OpenCompanyTenantSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步司机租户")
    @PostMapping("/tenant/sync/driver")
    public void syncDriver(@RequestBody @Valid OpenDriverTenantSyncDTO sync) {
        openSyncService.sync(sync);
    }

    @ApiOperation("同步失败")
    @PostMapping("/sync/fail")
    public List<String> syncFail(@RequestBody @Valid OpenSearchSourceDataDTO sync) {
        return openSyncService.getFailSourceData(sync);
    }

}
